const moment = require('moment');

module.exports = (db, DataTypes) => {
  return db.define('DutyShift', {
    // 交接班记录
    workBeginTime: DataTypes.STRING,
    workEndTime: DataTypes.STRING,
    teamName: DataTypes.STRING,
    workRecord: DataTypes.TEXT,

    // 破损记录单
    createdTime: {
      type: DataTypes.STRING,
      set() {
        let date = moment();
        let year = date.year();
        let month = date.month() + 1;
        let day = date.date();
        let hour = date.hour();
        let minute = date.minute();
        this.setDataValue('createdTime', `${year}年${month}月${day}日  ${hour.toString().length === 1 ? `0${hour}` : hour}:${minute.toString().length === 1 ? `0${minute}` : minute}`);
      },
    },
    baggageCode: DataTypes.STRING,
    airportCode: DataTypes.STRING,
    STD: DataTypes.STRING,
    inputTime: {
      type: DataTypes.STRING
    },
    inputLocation: {
      type: DataTypes.STRING
    },
    findTime: {
      type: DataTypes.STRING
    },
    findLocation: {
      type: DataTypes.STRING
    },
    findPerson: {
      type: DataTypes.STRING
    },
    analyze: {
      type: DataTypes.TEXT
    },
    result: {
      type: DataTypes.STRING
    },
    realFileName: {
      type: DataTypes.STRING
    },
    fileName: {
      type: DataTypes.STRING
    },
    downloadUrl: {
      type: DataTypes.STRING
    },

    // 行李查询单
    // createdTime
    // airportCode: DataTypes.STRING
    // baggageCode: DataTypes.STRING,
    ETD: DataTypes.STRING,
    BSM: DataTypes.STRING,
    firstTailLocation: DataTypes.STRING,
    firstTailTime: DataTypes.STRING,
    lastTailLocation: DataTypes.STRING,
    lastTailTime: DataTypes.STRING,
    securityLevel: DataTypes.STRING,
    systemInnerTime: DataTypes.STRING,
    reason: DataTypes.TEXT,

    // 异常行李单
    // createdTime
    // airportCode: DataTypes.STRING
    // baggageCode: DataTypes.STRING,
    // STD
    // inputTime
    // inputLocation
    // findTime
    // findLocation
    // findPerson
    baggageFeature: DataTypes.TEXT,
    remark: DataTypes.TEXT,
    isNormalLocation: DataTypes.BOOLEAN,
    // analyze

    type: DataTypes.STRING,  // ['dutyShift', 'posun', 'chaxun', 'yichang']
    createdAt: DataTypes.DATE,
    updatedAt: DataTypes.DATE,
  });
};
